home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
plane arcade
/
planearcade.exe
/
tank3.bmp
/
zaloha
/
model.h
< prev
next >
Wrap
C/C++ Source or Header
|
2004-09-19
|
5KB
|
204 lines
#ifndef _MODEL_H_
#define _MODEL_H_
//struktury modelov
#include "md2.h"
#include "shd.h"
//-----------------------------------
//FACE
//----------------------------------
struct MODELFACE
{
VECTOR3D P[3]; //vertexi
VECTOR2D T[3]; //texture kordinaty
VECTOR3D N[3]; //normaly
PLANE Plane; //rovina
};
//----------------------------------
//MODEL
//----------------------------------
struct MODELFRAME
{
//Face
int NumFaces;
int ActFace;
MODELFACE *FaceList;
VECTOR3D Min,Max; //minimalne - maximalne hodnoty
VECTOR3D P[8]; //body obaloveho kvadra
VECTOR3D Centre; //stred
VECTOR3D ZeroPoint; //transformovany bod 0,0,0
float Polomer; //polomer
};
//-----------------------------------
//CUSTOMVERTEX
//---------------------------------------
struct CUSTOMVERTEXMODEL
{
D3DXVECTOR3 pos; //Position
D3DXVECTOR3 normal; //normal
D3DCOLOR color;
FLOAT tu, tv;
};
//CUSTOMVERTEXT
#define D3DFVF_CUSTOMVERTEXMODEL (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1)
//------------------------------------------------------------------
// Name: MODEL class
// Desc: ***********
//------------------------------------------------------------------
class MODEL
{
private:
//vertex buffer
LPDIRECT3DVERTEXBUFFER9 g_pVB ;
//textura
LPDIRECT3DTEXTURE9 g_pTexture;
LPDIRECT3DTEXTURE9 g_pEnviroMap;
//material
D3DMATERIAL9 Material;
///////////
//FUNKCIE//
///////////
//zinicializuje vsetko - VB, modely
void SetNums(int NFrames, int NFaces);
///////////////////////////////////////
//POMOCNE FUNCKIE PRE PRACU S MODELOM//
///////////////////////////////////////
void CalcBoxPoints(MODELFRAME *Mod);
//vypocita minimum a maximum a stred
void CalcMinMax(MODELFRAME *Mod,D3DXMATRIXA16 Matica);
//vypocita Face Normaly, vypocita stred, zeropoint, MinMax
void CalcFaceNormals(MODELFRAME *Mod);
//vypocitaj smooth shading
void CalcSmoothShading(MODELFRAME *Mod);
//interpolacia
void InterpolateModel(MODELFRAME *Mod);
//transformacia - vypocita min max
void TransformModel(MODELFRAME *Mod,D3DXMATRIXA16 Matica);
//renderuje model
void RenderModelNormal(MODELFRAME Mod);
void RenderModelMultiTexture(MODELFRAME Mod);
void RenderModelEnvironment(MODELFRAME Mod);
void RenderModelBumpMap(MODELFRAME Mod);
void RenderModelOnlyShadow(MODELFRAME Mod);
//inicializacia
void InitializeModel(MODELFRAME *Mod,int NFaces);
//znicenie
void DestroyModel(MODELFRAME *Mod);
//////////////////////
//FUNKCIE - LOAD ASE//
//////////////////////
int GetNumFace(char *FileName);
void AddNode(MODELFRAME *Mod,FILE *fp);
public:
MODEL();
~MODEL();
MODELFRAME ModelFrame; //zasobnik modelu
//////////////
//VLASTNOSTI//
//////////////
D3DXMATRIXA16 Matica; //matica
VECTOR3D Pos; //pozicia
VECTOR3D Rot; //rotacia - yaw pitch roll
VECTOR3D Sca; //velkos¥
COLOR Color; //color
bool Lighting; //osvetlit model?
bool Specular ; //zapinat specular shading
bool Textured; //textura?
bool FrustrumTest; //test frustrum cullingu
bool SmoothShading; //ci ma pocitat smooth shading
bool Normals; //ci ma pocitat normaly
bool BumpMap; //bumpmapping
bool EnviromentMapping; //enviro mapping
bool MultiTexture; //enviro + normal
bool OnlyShadow; //render iba pre tiene
float Frame; //frame - animacia
int NumFaces; //pocet trojholnikov v jednom modely
int NumFrames; //pocet frejmov
//////////////////////
//FUNKCIE - LOAD ASE//
//////////////////////
void InitializeAse(int NFrames,char *FileName);
void LoadAse(int IntoFrame,char *FileName);
//////////////////////
//FUNKCIE - MD2 //
//////////////////////
void LoadMD2(char *FileName,int NFrames);
//////////////////////
//FUNKCIE - SHD //
//////////////////////
void LoadSHD(char *FileName);
void SaveSHD(char *FileName);
///////////////////////
//FUNKCIE - UNIVERZAL//
///////////////////////
void LoadTexture(char *FileName,COLOR ColorKey);
void LoadEnviroMap(char *FileName);
void SetMaterial(D3DMATERIAL9 Mat);
void BuildShadow(STENCIL *Stn);
void Render();
void RenderFast();
//////////////////////
//FUNKCIE - KOLIZIA/ /
//////////////////////
//vlastnosti kolizie
VECTOR3D ColPosition; //pozicia v ktorej doslo ku kolizii
VECTOR3D ColNormal; //normala facu ktory bol v kolizii
bool CollisionDetail(VECTOR3D P1, VECTOR3D P2,D3DXMATRIX PomMatrix);
bool CollisionBox(VECTOR3D P1, VECTOR3D P2,D3DXMATRIX PomMatrix);
};
#endif //_MODEL_H_